﻿//原始的例子
function pieChart(id, data){
    var myChart = echarts.init(document.getElementById(id));

    // 过渡---------------------
    myChart.showLoading({
        text: '正在努力的读取数据中...'
    });
	
	var  a=0;
	
	for(var i= 0,len=data.length; i<len; i++){
	
		a=a+data[i].value;
	
	}
	
    for(var i= 0,len=data.length; i<len; i++){
        (function(index){
            var value = parseInt(data[i].value);
            var itemColor = "#92D050";
            if(data[i].name == "已占用"){	
                if(value/a >= 0.9){
                    itemColor = "#FF0000";
                }else if(value/a >= 0.6){
                    itemColor = "#FF6400";
                }else{
                    itemColor = "#FFB400";
                }
                data[i].selected = true;
            }
            var itemStyle = {
                normal: {
                    color: itemColor
                }
            }
            data[i].itemStyle = itemStyle;
        })(i);
    }

    var option = {
		tooltip : {
        
        formatter: "{a} <br/>{b} : {c} ({d}%)"

		
    },
        series : [
            {
                name:'',
                type:'pie',
                selectedMode: 'single',
                radius : [0, 70],
                x: '10%',
                width: '40%',
                funnelAlign: 'right',
                max: 100,
                itemStyle : {
                    
                    emphasis : {
                        
                    }
                },
                data:data
            }
        ]
    };
    myChart.hideLoading();
    myChart.setOption(option);

}

//队列方法	
function pieCharhost(id, data){
    var myChart = echarts.init(document.getElementById(id));

    // 过渡---------------------
    myChart.showLoading({
        text: '正在努力的读取数据中...'
    });
	
	
    for(var i= 0,len=data.length; i<len; i++){
        (function(index){
            var value = parseInt(data[i].value);
            var itemColor = "#92D050";
            if(data[i].name == "已占用"){	
                if(value >= 90){
                    itemColor = "#FF0000";
                }else if(value >= 60){
                    itemColor = "#FF6400";
                }else{
                    itemColor = "#FFB400";
                }
                data[i].selected = true;
            }
            var itemStyle = {
                normal: {
                    color: itemColor
                }
            }
            data[i].itemStyle = itemStyle;
        })(i);
    }

    var option = {
		tooltip : {
        
        formatter: "{a} <br/>{b} : {c} ({d}%)"

		
    },
        series : [
            {
                name:'队列整体使用百分比',
                type:'pie',
                selectedMode: 'single',
                radius : [0, 70],
                x: '10%',
                width: '40%',
                funnelAlign: 'right',
                max: 100,
                itemStyle : {
                    
                    emphasis : {
                        
                    }
                },
                data:data
            }
        ]
    };
    myChart.hideLoading();
    myChart.setOption(option);

}


//hdfs方法
function pieCharhdfs(id, data){
    var myChart = echarts.init(document.getElementById(id));

    // 过渡---------------------
    myChart.showLoading({
        text: '正在努力的读取数据中...'
    });
	
	var  a=0;
	
	for(var i= 0,len=data.length; i<len; i++){
	
		a=a+data[i].value;
	
	}
	
    for(var i= 0,len=data.length; i<len; i++){
        (function(index){
            var value = parseInt(data[i].value);
            var itemColor = "#92D050";
                if(value >= 90){
                    itemColor = "#FF0000";
                }else if(value >= 60){
                    itemColor = "#FF6400";
                }else{
                    itemColor = "#FFB400";
                }
                data[i].selected = true;    
            var itemStyle = {
                normal: {
                    color: itemColor
                }
            }
            data[i].itemStyle = itemStyle;
        })(i);
    }

    var option = {
		tooltip : {
        
        formatter: "{a} <br/>{b} : {c} ({d}%)"

		
    },
        series : [
            {
                name:'HDSF存储使用情况',
                type:'pie',
                selectedMode: 'single',
                radius : [0, 70],
                x: '10%',
                width: '40%',
                funnelAlign: 'right',
                max: 100,
                itemStyle : {
                    
                    emphasis : {
                        
                    }
                },
                data:data
            }
        ]
    };
    myChart.hideLoading();
    myChart.setOption(option);

}

